<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
    <style>
      body {
        padding: 100px;
      }

      #div1 {
        width: 400px;
        height: 400px;
        background: red;
        padding: 50px;
      }

      #div2 {
        height: 300px;
        background: green;
        padding: 50px;
        text-align: center;
        line-height: 300px;
      }

      #span {
        background: yellow;
        border: 10px solid red;
        padding: 10px 30px;
      }
    </style>
  </head>

  <body>
    <div id="div1">
      <div id="div2">
        <span id="span">This is a span.</span>
      </div>
    </div>
    <script>
      var div1 = document.getElementById('div1');
      div1.onmouseover = function (e) {
        console.log('div1监听到移入',"target:",e.target);
        // console.log(e.bubbles);
      };
      div1.onmouseout = function (e) {
        console.log('div1监听到移出',"target:",e.target);
        // console.log(e.bubbles);
      };

      // 父节点监听事件所以从div2到div1的时候 也会有一个div1移出和div1移入
      // 为什么div2->div1会有移出？
    </script>
  </body>
</html>
